<?php
/**
 * 统计控制器
 */

namespace app\admin\controller;

use Exception;
use think\Request;
use think\db\Query;
use think\response\Json;
use app\common\model\Tongji;
use app\common\model\User;
use app\common\model\Type;
use app\common\model\Parent;
use app\common\model\Spec;
use app\common\model\Brand;

use app\common\validate\TongjiValidate;

class TongjiController extends AdminBaseController
{

    /**
     * 列表
     * @param Request $request
     * @param Tongji $model
     * @return string
     * @throws Exception
     */
    public function index(Request $request, Tongji $model): string
    {
        $param = $request->param();
        $data  = $model->with(['user','type','parent','spec','brand',])->scope('where', $param)
            ->paginate([
                'list_rows' => $this->admin['admin_list_rows'],
                'var_page'  => 'page',
                'query'     => $request->get(),
            ]);
        // 关键词，排序等赋值
        $this->assign($request->get());

        $this->assign([
            'data'  => $data,
            'page'  => $data->render(),
            'total' => $data->total(),
            'user_list' => User::select(),
'type_list' => Type::select(),
'parent_list' => Parent::select(),

        ]);
        return $this->fetch();
    }















}
